//
//  NetWorkViewController.m
//  test
//
//  Created by mac on 2017/8/31.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "NetWorkViewController.h"
#import "NetWorkHelper.h"

@interface NetWorkViewController ()
{
    UILabel *label;
}

@end

@implementation NetWorkViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor =[UIColor whiteColor];
    label = [[UILabel alloc]initWithFrame:CGRectMake(0,50,self.view.frame.size.width,200)];
    label.text= @"Hello iSmart!";
    label.textColor = [UIColor orangeColor];
    label.font=[UIFont
                fontWithName:@"Arial-BoldItalicMT"
                size:32];
    [label setTextAlignment:NSTextAlignmentCenter];
    label.shadowColor = [UIColor blackColor];
    [self.view addSubview:label];
    
    
    UIButton *btn_get = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    CGRect frame0;
    frame0.size.width = 150;
    frame0.size.height = 40;
    frame0.origin.x = self.view.frame.size.width / 2 - 75;
    frame0.origin.y = self.view.frame.size.height / 2;
    [btn_get setFrame:frame0];
    [btn_get setTitle:@"get" forState:UIControlStateNormal];
    [btn_get addTarget:self action:@selector(btn_get) forControlEvents:UIControlEventTouchUpInside];
    [btn_get setBackgroundColor:[UIColor orangeColor]];
    [btn_get setAlpha:0.8];
    btn_get.layer.cornerRadius=5;
    [btn_get setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:btn_get];
    
    UIButton *btn_post = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    CGRect frame1;
    frame1.size.width = 150;
    frame1.size.height = 40;
    frame1.origin.x = self.view.frame.size.width / 2 - 75;
    frame1.origin.y = self.view.frame.size.height / 2 +50;
    [btn_post setFrame:frame1];
    [btn_post setTitle:@"post" forState:UIControlStateNormal];
    [btn_post addTarget:self action:@selector(btn_post) forControlEvents:UIControlEventTouchUpInside];
    [btn_post setBackgroundColor:[UIColor orangeColor]];
    [btn_post setAlpha:0.8];
    btn_post.layer.cornerRadius=5;
    [btn_post setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:btn_post];

}
-(void)btn_get{
    NetWorkHelper *net = [[NetWorkHelper alloc]initWithUrl:@""];
    [net GET:@"http://playschool.go.c2d.me/api/test/ios/get" cacheKey:@"cacheKey" completion:^(BOOL success, NSDictionary *data) {
        //处理你的请求
        NSLog(@"%@",data);
    }];
}

-(void)btn_post{
    NetWorkHelper *net = [[NetWorkHelper alloc]initWithUrl:@""];
    [net POST:@"http://playschool.go.c2d.me/api/test/ios/get" cacheKey:@"cacheKey" params:@{@"username":@"wdh",@"password":@"test"} compile:^(BOOL success, NSDictionary *data) {
        //处理你的请求
        NSLog(@"%@",data);
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
